<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="common/include :: header('新增定时任务')"/>
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
            <div class="layui-form-item">
                <label class="layui-form-label required ">任务名称</label>
                <div class="layui-input-block">
                    <input type="text" name="jobName"
                           lay-verify="required" lay-reqtext="任务名称不能为空"
                           placeholder="请输入任务名称" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required ">调用目标字符串</label>
                <div class="layui-input-block">
                    <input type="text" name="invokeTarget"
                           lay-verify="required" lay-reqtext="调用目标字符串不能为空"
                           placeholder="请输入调用目标字符串" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required ">cron 表达式</label>
                <div class="layui-input-block">
                    <input type="text" name="cronExpression"
                           lay-verify="required" lay-reqtext="cron 表达式不能为空"
                           placeholder="请输入cron 表达式" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label  ">执行策略</label>
                <div class="layui-input-block">
                    <input type="text" name="executionPolicy"
                           
                           placeholder="请输入执行策略" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label  ">是否并发执行</label>
                <div class="layui-input-block">
                    <input type="text" name="isConcurrent"
                           
                           placeholder="请输入是否并发执行" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label  ">备注信息</label>
                <div class="layui-input-block">
                    <input type="text" name="remark"
                           
                           placeholder="请输入备注信息" value="" class="layui-input">
                </div>
            </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer"/>

<script th:inline="javascript">
    layui.use(['form', 'laydate'], function () {
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer,
            $ = layui.$;


        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: ctx + 'quartzJob/insert',
                type: 'POST',
                async: false,
                contentType: 'application/json; charset=UTF-8',
                dataType: "json",
                data: JSON.stringify(data.field),
                success: function (res) {
                    var index = layer.alert(res.msg, {
                        title: '提示信息'
                    }, function () {
                        // 重新加载列表
                        window.parent.location.reload();
                        // 关闭弹出层
                        layer.close(index);
                        var iframeIndex = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(iframeIndex);
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.close(index);
                    if (XMLHttpRequest.status == 404) {
                        window.location.href = "404";
                    } else {
                        layer.msg("服务器好像出了点问题！请稍后试试");
                    }
                }
            });

            return false;
        });

    });
</script>